<?php if (!defined('THINK_PATH')) exit();?><!--<div class="yuSuo clearfix" style="float:left;">
        <form id="searchFrom">
            <input id="status" name="status" type="hidden" value="<?php echo ($params["status"]); ?>"/>
            <?php if($params['status']== 1): ?> 
            <input type="text" id="start_time" name="start_time" value="<?php echo ($params["trace_start_time"]); ?>" placeholder="跟踪时间" readonly /><em></em>
            <input type="text" id="end_time" name="end_time" value="<?php echo ($params["trace_end_time"]); ?>" placeholder="跟踪时间" readonly />
            <?php elseif($params['status']==3 || $params['status']==4): ?> 
            <input type="text" id="start_time" name="start_time" value="<?php echo ($params["sign_start_time"]); ?>" placeholder="预约时间" readonly /><em></em>
            <input type="text" id="end_time" name="end_time" value="<?php echo ($params["sign_end_time"]); ?>" placeholder="预约时间" readonly />            
             <?php endif;?>

            <input type="text" name="order_no" value="<?php echo ($params["order_no"]); ?>"  placeholder="拍卖单号"  class="suoDian suoDian1">
            <input type="button" onclick="search();" value="搜索" class="suoSou" style="width:80px;">
            <?php if($params['status']== 1 || $params['status']==3 || $params['status']==4): ?> 
            <input type="button" onclick="resetSearch();" value="重置" class="suoSou" style="width:80px;">
             <?php endif;?>
        </form>
</div>-->
<div class="yuList">
  <table class="table table-bordered">
    <thead>
      <tr>
        <th width="10%">拍卖单号</th>
        <th width="15%">车型</th>
        <th width="6%">所在地</th>
        <?php if($params['status']==0 ||$params['status']==1 || $params['status']==2 ):?>
        <th width="6%">车主姓名</th>
        <th width="9%">车主电话</th>
        <?php endif;?>
        <th width="8%">第一名出价</th>
        <th width="7%">保留价</th>
        <?php if($params['auth'] && $params['status']!=0 && $params['status']!=4):?>
          <th width="6%">操作客服</th>
        <?php endif;?>
        <?php if($params['status']==1):?>
          <th width="14%">下次跟踪时间</th>
        <?php elseif($params['status']==3):?>
          <th width="10%">确认时间</th>
        <?php endif;?>
        <th width="6%">操作</th>
      </tr>
    </thead>
    <tbody>
      <?php if(is_array($list)): $k = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$list): $mod = ($k % 2 );++$k;?><tr>
          <td><?php echo ($list["order_no"]); ?></td>
          <td>
            <a href="/Car/report/car_id/<?php echo ($list["car_id"]); ?>" target="_blank" class="cheText"><?php echo ($list["model"]); ?></a>
          </td>
          <td><?php echo ($list["location_area"]); ?></td>
          <?php if($params['status']==0 ||$params['status']==1 || $params['status']==2 ):?>
          <td><?php echo ($list["seller_name"]); ?></td>
           <?php if($_GET['status']== 0): ?><td><?php echo ($list["phone_has_star"]); ?></td>
           <?php else: ?>
               <td><?php echo ($list["phone"]); ?></td><?php endif; ?>
           <?php endif;?>
           <td><?php echo ($list["best_price"]); ?>元</td>
            <td><?php echo ($list["reserve_price"]); ?>元</td>
           <?php if($params['auth'] && $params['status']!=0 && $params['status']!=4):?>
            <td><?php echo ($list["owner_service"]); ?></td>
           <?php endif;?>
           <?php if($params['status']==1):?>
            <td><?php echo ($list["next_trace_time"]); ?></td>
          <?php elseif($params['status']==3):?>
            <td><?php echo ($list["owner_confirm_time"]); ?></td>
        <?php endif;?>
           <td>
               <?php if($list[status] == 5 AND $list[is_consult] == 0): if($_GET['status']== 0): ?><a href="/AuOrder/owner_confirm_detail/order_id/<?php echo ($list["order_id"]); ?>">确认</a>
                       <?php else: ?>
                       <?php if($params['emp_id'] == $list['owner_confirm_service_id']): if($params["fenpei_auth"] == true): ?><a href="/AuOrder/owner_confirm_detail/order_id/<?php echo ($list["order_id"]); ?>" >确认</a>
                                <a href="javascript:;" onclick="fenpei('<?php echo ($list["order_id"]); ?>');">分配</a>
                                <?php else: ?>
                                <a href="/AuOrder/owner_confirm_detail/order_id/<?php echo ($list["order_id"]); ?>">确认</a><?php endif; ?>

                       <?php elseif($params["fenpei_auth"] AND $params['emp_id'] != $list['owner_confirm_service_id']): ?>
                           <a href="javascript:;" onclick="fenpei('<?php echo ($list["order_id"]); ?>');">分配</a><?php endif; endif; ?>
               <?php elseif(($list[status] >= 7) OR ($list[status] == 5 AND $list[is_consult] == 1) ): ?>
                   <a href="/AuOrder/owner_confirm_detail/status/<?php echo ($params["status"]); ?>/order_id/<?php echo ($list["order_id"]); ?>" target="_blank">查看</a><?php endif; ?>

               <?php if($params['status'] != 4 and $list[is_valid] == 1 and $list[status] == 12 and ($list[fail_type] == 2 or $list[fail_type] == 6) and $list[car_status] == 8): ?><a href="javascript:;" onclick="re_auction('<?php echo ($list["order_id"]); ?>','<?php echo ($list["owner_id"]); ?>')">重拍</a>
                   <?php elseif($params['status'] != 4 and ($list[status] == 12) and ($list[fail_type] == 2 or $list[fail_type] == 6 )): ?>
                   <a href="javascript:void(0);" style="color:#7f7f7f;">已重拍</a><?php endif; ?>
           </td>       
        </tr><?php endforeach; endif; else: echo "" ;endif; ?>
       <div class="listBox" id="listBox"></div>
         <!--充值弹出窗口-->
            <div class="yunBei" style="display:none"></div>
                <form id="add_fm">
                    <div class="tanShang tanShang6" style="display:none;padding-bottom:50px;">
                        <h3>重拍</h3>
                        <ul class="daiJingW">
                            <li class="clearfix">
                                <h1 style="text-align:center">您确定将此车辆<b style="color:red"> 重拍 </b>吗？</h1>
                            </li>
                            <li class="clearfix">
                                <span style="width:90px; text-align:right;float:left;margin-left:20px;">保留价：</span>
                                <input style="width: 250px;" type="text" name="reserve_price" onclick="if (this.value == '请输入金额') this.value = '';" value="请输入金额" />
                                <em>元</em>
                            </li>
                            <li class="clearfix">
                                <div class="limit">
                                    <input type="hidden" id="last_transfer_limit" name="last_transfer_limit" value=""/>
                                    <input type="hidden" id="transfer_limit" name="transfer_limit" value=""/>
                                    <span>过户限制：</span>
                                    <?php foreach(C('TRANSFER_LIMIT') as $tk=>$val):?>
                                    <em id="tlk_<?php echo ($tk); ?>" class="<?php echo $detail['transfer_limit']==$tk ? 'active' : '' ;?>" data-id="<?php echo ($tk); ?>"><?php echo ($val); ?></em>
                                    <?php endforeach;?>
                                </div>
                            </li>
                            <li class="clearfix">
                                <input type="hidden" name="order_id">
                                <input type="hidden" name="owner_id">
                                <input type="button" value="确定" class="queding" id="qd_re_auction"/>
                                <input type="button" value="取消" class="quxiao" />
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
    </tbody>
  </table>
 </div>
 <div class="pageFaye"><div class="pager"><?php echo ($page); ?></div><div class="clear"></div></div>
</div>
<div class="deparHover" style="height: 200px;">
    <h4>分配客服</h4>
    <label>
        <select name="service_id" id="service_id" style="float: right;width: 360px;">
            <option value="0">请选择客服</option>
            <?php foreach($kfs as $kf):?>
            <option value="<?php echo ($kf["emp_id"]); ?>"><?php echo ($kf["real_name"]); ?></option>
            <?php endforeach;?>
        </select>
        分配给：
    </label>
    <div class="deparBtn">
        <input type="button" value="确定" class="deparQue" id="fenpeiQueding">
        <input type="button" value="取消" id="fenpeiQuxiao">
    </div>
</div>

<script>
    function limit(){
        $(".limit em").click(function(){
            $(".limit em").removeClass("active");
            $(this).addClass("active")
            $("#transfer_limit").val($(this).attr('data-id'));
        })
    }
    limit();
$("#start_time").ymdateplugin({
    changeMonth: true,
    changeYear: true
});

$("#end_time").ymdateplugin({
    changeMonth: true,
    changeYear: true
});

function fenpei(order_id){
        var bg = $(".yunBei");
        var pp = $(".deparHover");
        var qd = $("#fenpeiQueding");
        var qx = $("#fenpeiQuxiao");

        $("#service_id").select2();
        bg.show();
        pp.show();
        $([bg,qd,qx]).each(function(i,n){
            $(n).unbind('click');
        });
        qx.click(hide_pp);
        bg.click(hide_pp);
        qd.click(function(){
            var service_id = $("#service_id").val();
            $.post("/AuOrder/assignServer",{"order_id":order_id, "service_id":service_id},function(data){
                if(data.code != 200){
                    shibai_alert(data.msg, 1500);
                    return false;
                }
                btn_alert("分配成功",1000,function(){
                    window.location.reload();
                });
            },"json");
        });
        function hide_pp(){
            bg.hide();
            pp.hide();
            bg.unbind('click');
        }
    }



function re_auction(order_id,owner_id){
    $.post("/AuOrder/re_auction_detail", {'order_id':order_id}, function (data) {
        if(data.code == '200'){
            $("#last_transfer_limit").val(data.data.transfer_limit);
            $("#transfer_limit").val(data.data.transfer_limit);
            $("input[name='reserve_price']").val(data.data.reserve_price);
            $(".limit em").removeClass("active");
            $("#tlk_" + data.data.transfer_limit).addClass("active");
            $("input[name='order_id']").val(order_id);
            $("input[name='owner_id']").val(owner_id);
            $('.yunBei,.tanShang').show();
        }else{
            shibai_alert(data.msg);
        }
    }, "json");
}

$("#qd_re_auction").on('click',function(){
        var order_id = $("input[name='order_id']").val();
        var owner_id = $("input[name='owner_id']").val();
        var reserve_price = $("input[name='reserve_price']").val();
        var last_transfer_limit = $("#last_transfer_limit").val();
        var transfer_limit = $("#transfer_limit").val();
        var params = {
            'order_id':order_id,
            'owner_id':owner_id,
            'reserve_price':reserve_price,
            'last_transfer_limit':last_transfer_limit,
            'transfer_limit':transfer_limit
        };
        $.post("/AuOrder/re_auction", params, function (data) {
            if (data.code == '200') {
                btn_alert(data.msg, 2000, function () {
                    window.location.reload()
                });
            } else {
                shibai_alert(data.msg);
            }
        }, "json");
    });

$(".tanShang ul li .quxiao").click(function(){
    $(".tanShang").fadeOut();
    $(".yunBei").css("display","none");
});
function resetSearch(){
  $("#start_time").val('');
  $("#end_time").val('');
  $("input[name='order_no']").val('');
}

</script>